﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.OracleClient;
using TracNghiem.Models;
using System.Configuration;
using System.Data;

namespace TracNghiem.Areas.Admin.Models
{
    public class noidungdonModels
    {
        
        public string id { get; set; }
        //1 la gioi thieu 2 la lien ket
        public string noidung { get; set; }
        /// <summary>
        /// lấy nội dung id=1 là giới thiệu
        /// </summary>
        /// <param name="_id"></param>
        /// <returns></returns>
        public noidungdonModels GETNOIDUNG(int _id)
        {

            OracleDataReader odr = General.Lib_GetDataReader("SELECT *  FROM noidungdon where id="+_id);
            noidungdonModels kq = new noidungdonModels();
            while (odr.Read())
            {

                    kq.id = odr["id"].ToString();
                    kq.noidung = odr["noidung"].ToString();
                    

              
            }
            General.conn_global.Close();
            return kq;
        }

 public void CapNhat(noidungdonModels nd)
{
    string str = ConfigurationManager.ConnectionStrings["tracnghiem"].ConnectionString;
    OracleConnection conn = new OracleConnection(str);
    OracleCommand cmd = new OracleCommand("gioithieu", conn);
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.Parameters.Add("ID_", OracleType.Number).Value = nd.id;
    
    cmd.Parameters.Add("NOIDUNG_", OracleType.Clob).Value = nd.noidung;

    conn.Open();
    cmd.ExecuteNonQuery();
    conn.Close();
}

    }
}